package client.comm.baoding.fragment

import android.text.TextUtils
import client.comm.baoding.R
import client.comm.baoding.api.bean.UserInfo
import client.comm.baoding.databinding.FragmentZz2TwoBinding
import client.comm.baoding.ui.vm.Zz2ViewModel
import client.comm.commlib.base.BaseFragment
import client.comm.commlib.dialog.ValidatePwdDialog
import client.comm.commlib.toast.toast
import client.comm.commlib.utils.StoreUtil

class Zz2TwoFragment : BaseFragment<FragmentZz2TwoBinding, Zz2ViewModel>() {

    override fun getViewId(): Int {
        return R.layout.fragment_zz2_two
    }

    override fun initViewModel(): Zz2ViewModel = createViewModel()

    override fun initWidget() {
        binding?.apply {
            event = this@Zz2TwoFragment
            vm = viewModel
            StoreUtil.getBean<UserInfo>(requireContext())?.let {
                viewModel.userInfo.value = it
                inconme = it.income.toString()
                integral = "999.00"
            }
        }

    }

    override fun initData() {

    }

    fun okWithSys() {
        if (TextUtils.isEmpty(viewModel.zzNum.value)||viewModel.zzType.value!! < 0) {
            toast("所有不能为空")
            return
        }
        ValidatePwdDialog(requireContext()).apply {
            title = "需要验证支付密码"
            ok = {
                viewModel.okWithSys(it)
            }
        }.show()
    }


}